/**
 * 
 */
package cn.zhucongqi;

import java.util.List;

import com.jfinal.ext2.core.ControllerExt;
import com.jfinal.ext2.upload.filerenamepolicy.DateRandomFileRenamePolicy;
import com.jfinal.upload.OreillyCos;
import com.jfinal.upload.UploadFile;

/**
 * @author BruceZCQ
 * Jun 22, 20154:55:18 PM
 */
public class UploadController extends ControllerExt {

	public void index(){

	String parent = "zcq";
		
		DateRandomFileRenamePolicy policy = new DateRandomFileRenamePolicy(parent,"zz"); 
		
//		List<UploadFile> files = this.getFiles();
//		
//		StringBuilder sb = new StringBuilder();
//		for (UploadFile file : files) {
//			
//			String info = "origin==>"+file.getFileName()+
//					"\nFileSavePath=>"+policy.getAppParentDateDir()+
//					"\n path =>"+file.getFile().getAbsolutePath()
//					+"\n savepath" + file.getSaveDirectory()
//					+ "\n db info >>"+policy.getAppParentDateDir()+file.getFileName();
//			sb.append("\n\n\n").append(info);
//		}
//		this.renderText(sb.toString()+name);
		
		UploadFile img123 = this.getFile("img123", policy);
		String name = this.getPara("name");
		UploadFile img = this.getFile("img1", policy);
		
		this.renderText("image"+img123.getFileName()+"ing=>"+img.getFileName()+policy.getAppParentDateDir());
		
//		UploadFile file = this.getFile("img", policy);
		
		//		UploadFile file = this.getFile("img", new CustomParentDirFileRenamePolicy("BruceZCQ",NamePolicy.ORIGINAL_NAME));
//		this.renderText("origin==>"+file.getOriginalFileName()+"path=>"+file.getFile().getAbsolutePath());
	}

	@Override
	public void onExceptionError(Exception e) {
		// TODO Auto-generated method stub
		
	}
	
//	public void dateFileRenampolicy(){
//		DateRandomFileRenamePolicy policy = new DateRandomFileRenamePolicy("group"); 
//		UploadFile file = this.getFile("img", policy);
//		//this.renderText("origin==>"+file.getOriginalFileName()+"\npath=>"+file.getFile().getAbsolutePath()+"\nFileSavePath=>"+policy.getFileSavePath());
//	}
}
